<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where yo u can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome'); 
});


/**
*   前台头部
 */
Route::get('home/index','home\RegisterController@index');

/**
 *  邮箱注册
 */
Route::post('/home/register','home\RegisterController@register');

/**
 *  手机注册
 */
Route::post('/home/doregister','home\RegisterController@doregister');


/**
*   验证码验证
 */
Route::get('vcode','home\RegisterController@vcode');

/**
*   手机验证
 */
Route::get('/home/dophone','home\RegisterController@dophone');

/**
*   用户名验证
 */
Route::get('/home/douser','home\RegisterController@douser');

/**
*   邮箱验证
 */
Route::get('/home/doemail','home\RegisterController@doemail');

/**
*   验证码验 证
 */
Route::get('/home/docode','home\RegisterController@docode');

/**
*   前台个人中心
 */
Route::controller('home','Home\CenterController');


//前台购物 车
 Route::controller('/Home/car','Home\CarController');

 //前台地址 
 Route::controller('/Home/address','Home\AddressController');
// //后台订单 
 Route::controller('/Admin/order','Admin\OrderController');


//前台商城首页
Route::get('Home','Home\HomepageController@index');
//前台登陆首页注册
Route::get('/home/index','Home\RegisterController@index');
//登陆验证
Route::controller('/Home/login','Home\LoginController');
//登陆验证码
Route::get('vcode','Home\RegisterController@vcode');
//找回密码
Route::controller('Home/retpwd','Home\RetpwdController');
//404页面
Route::get('/Home/error','Home\ErrorController@index');

// 列表页控制器 list为关键字 所以在list前加l为llist
Route::controller('/Home/homelist','Home\HomelistController');

//搜索
Route::post('/Home/homepage','Home\HomepageController@find');

//商品详情
Route::controller('/Home/goodsdetails','Home\GoodsdetailsController');
//我喜欢
Route::controller('/Home/like','Home\LikeController');


/**
 *  通用功能路由组
 */
Route::group(['namespace' =>'Coms', 'prefix' => 'Coms'], function () {

    Route::get('/login-code',['as' => 'coms.login-code', 'uses' => 'ComsController@loginCode']);
});

/**
 * 后台登录
 */

Route::group([ 'prefix'=>'admin', 'namespace' => 'Admin'], function(){

    Route::get('/login',['as'=>'admin.login', 'uses' => 'LoginController@loginPage']);
    Route::post('/login/doLogin',['as'=> 'admin.doLogin', 'uses' => 'LoginController@doLogin']);
    Route::get('/login/loginOut', ['as'=>'admin.loginOut', 'uses' => 'LoginController@loginOut']);

});

//        疑惑点: 在角色管理中的any为什么不能换为post

/**
 * 后台的所有操作
 */

Route::group(['middleware'=>'login','namespace'=>'Admin'],function(){
    // 权限管理
        //管理员列表操作
        Route::get('/admin/admin', ['as'=>'admin.welcome',  'uses' => 'AdminController@welcomePage']);
        Route::get('/admin/edit/{id?}', ['as'=> 'admin.edit', 'uses' =>'AdminController@adminEditPage']);
        Route::any('/admin/save/{id?}', ['as' => 'admin.save', 'uses' =>'AdminController@adminCreateOrSave']);
        Route::any('/admin/del/{id?}', ['as' => 'admin.del', 'uses' =>'AdminController@adminDel']);

        //管理员分配角色 分配节点
        Route::get('/distri/role_load/{id?}', ['as' => 'distri.loadRole', 'uses' => 'DistriController@loadRole']);
        Route::post('/distri/role_save',['as' =>'distri.saveRole', 'uses' =>'DistriController@saveRole']);
        Route::get('/distri/node_load/{id?}', ['as' => 'distri.loadNode', 'uses' => 'DistriController@loadNode']);
        Route::post('/distri/node_save',['as' => 'distri.saveNode', 'uses' =>'DistriController@saveNode']);

        //角色管理
        Route::get('/admin/role',['as' =>'admin.role', 'uses' =>'RoleController@rolePage']);
        Route::any('/admin/role/create_save/{id?}', ['as' => 'admin.role.createOrSave', 'uses' => 'RoleController@createOrSave']);
        Route::get('/admin/role/edit/{id?}', ['as' => 'admin.role.edit', 'uses' => 'RoleController@editPage']);
        Route::any("/admin/role/delete/{id?}", ['as' =>'admin.role.del', 'uses' =>'RoleController@del']);

//    //角色管理控制器
//    Route::resource('/Admin/role','RoleController');
//
//    //管理员分配角色  分配节点
//    Route::controller('/Admin/distri','DistriController');
//
//     Route::resource('/Admin/admin','AdminController');

    //节点控制器
    Route::resource('/Admin/node','NodeController');



    //后台首页
	Route::get('/Admin/user/index','UserController@index');

	//后台用户控制器
    Route::controller('Admin/user','UserController');

 	//后台分类控制器
 	Route::controller('/Admin/admincate','AdmincateController');
   
    //后台订单 
    Route::controller('/Admin/order','OrderController');

	//商品管理
	Route::controller('/Admin/goods','GoodsController');



	

	


	 //评价管理
	 Route::controller('/Admin/comment','CommentController');

	 //网站配置管理
	 Route::controller('/Admin/config','ConfigController');

});

 
  